<%user = comment.user%>
<%requirement = comment.requirement%>
<div class="singlework">
	<div class="designer">
    	<div class="title">
    		<p>作品编号：<%= comment.id%></p>
		</div>
        <div class="des_info">
        	<%= image_tag(user.avatar.url)%>
			<p><%= link_to user.username, profile_for(user)%></p>
            <ul>
                <li>姓名：<%= user.name.or_else("未填写")%></li>
                <li>公司：<%= user.company.or_else("未填写")%></li>
                <li>中标次数：n次</li>                      
            </ul>
			<div class="op">
			<% unless Friendship.exists?(@login_user,user)%>
				<%= link_to "加为好友",{ :controller => "/friendship",
										:action => "create",
                                  		:id => user.username },
									:confirm => "加#{user.username}为好友?"%>
			<% end %>
			<%= link_to "发站内信", :action => :send_message, 
								   :controller => "/message",
								   :username => @login_user.username %>
			</div>								   
        </div>
	</div>
	<div class="work">
    	<div class="title">
    		<p>
    			<span>竞标时间：<%= comment.created_at.to_s(:db)%></span>
				<div id="store_comment_<%=comment.id%>" class="store_comment">
					<%= link_to_remote "收藏", :url => { :controller => :store,
														:action => :comment,
														:id => comment },
											   :method => :get,
											   :confirm => "确定收藏该作品吗？" %>
				</div>
				<% if @login_user == requirement.user -%>
				<div id="requirement_<%=requirement.id%>">
					<% if RequirementOrder.exists?(user,requirement)%>
						<% if requirement.solver_exists?%>
						<p>方案解决者</p>
						<%else%>
						<div class="select_order">
							<%= link_to_remote "删除该接单者", :url => { :action => :delete_order, 
																	   :controller => "/requirement", 
												                       :username => user.username,
																	   :id => requirement},
															 :update => "requirement_#{requirement.id}" %>
							<%= link_to_remote "设为解决方案", :url => {:action => :choose_solver, 
																	  :controller => "/requirement", 
												                      :username => user.username,
																	  :id => requirement},
															 :update => "requirement_#{requirement.id}" %>
						    <% end %>
						</div>										 
					<% else %>
						<div class="select_order">
						<%= link_to_remote "选为接单者", :url => {:action => :choose_order,
																:controller => "/requirement",
																:id => requirement,
																:username => user.username},
														:update => "requirement_#{requirement.id}" %>
						</div>														
					<% end %>
				</div>	
				<% end %>
				<div></div>
			</p>
       	</div>
        <div class="work_info">
        	<ul>
            	<li>报价：<%= comment.price -%>元</li>
				<li>交付周期：<%= comment.need_days -%>天</li>
				<li>设计描述：<%= simple_format comment.content -%></li>
            </ul>
			<% if comment.attach.exists? -%>     
            <%= render :partial => "requirement/download_comment", :locals => { :comment => comment} %>
			<% end %>
   		</div>
	</div>
</div>